﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using BLL;
using Model;
using System.Reflection;
//这个类负责加载题的信息：题目，正确答案，分值

namespace NCRE学生考试端V1._0
{
    public class WordLoadinfo 
    {
        public WordQuestionEntityBll wordquestionbll = new WordQuestionEntityBll();
        public static List<WordQuestionRecordEntity> list = new List<WordQuestionRecordEntity>();

        #region 利用全局变量，根据试卷类型取出该类型下的所有题库中的题  2015年12月21日 李少然
        /// <summary>
        /// 获取考试内容的界面
        /// </summary>
        /// <param name="wordinfo">传递考试类型</param>
        /// <returns>返回考试内容</returns>
        public DataTable SelectTestByPaperType()
        {
            string PaperType;
            PaperType = MyInfo.MyPaperType();
            //根据学号查询该学生要考的试题和试卷类型，
            return wordquestionbll.LoadWordByPaperType(PaperType);
        }
        #endregion


        #region 把循环给分的一部分给抽出来，减少重复性  2015年12月21日 李少然 孟海滨
        /// <summary>
        /// 根据题库的信息和学生答题信息来决定分数
        /// </summary>
        /// <param name="drs">题库信息</param>
        /// <param name="studentrecord">学生答题的信息</param>
        /// <returns></returns>
        public WordQuestionRecordEntity getStudentRecord(DataRow[] drs, WordQuestionRecordEntity studentrecord)
        {
            int count = 0;
            string strAnswer = string.Empty;
            string strFration = string.Empty;
            foreach (DataRow item in drs)
            {
                string strRightAnswer = item["RightAnswer"].ToString();                
                if (studentrecord.ExamAnswer == item["RightAnswer"].ToString ())
                {
                    //加分
                    strAnswer = strRightAnswer;
                    strFration = item["Fration"].ToString();
                    count++;
                }

            }

            if (count > 0)
            {
                studentrecord.Fration = strFration;
            }
            else
            {
                studentrecord.Fration = "0";
            }
            return studentrecord;

        } 
        #endregion
    }
}
